<template>
	<view class="content">
		<view style="height: 1rpx;background-color: #FFFFFF;"></view>
		
		<view class="topTab">
			<uTabs
				:list="itemList"
				lineWidth="50"
				lineColor="#08C8BD"
				:activeStyle="{
					color: '#08C8BD',
					fontWeight: 'bold',
					transform: 'scale(1.05)'
				}"
				:inactiveStyle="{
					color: '#505E5C',
					transform: 'scale(1)'
				}"
				itemStyle="width:140rpx; height: 34px;"
				@click="tabClick"
			>
			</uTabs>
		</view>
		<view class="" v-for="(item,index) in presentList" :key="index">
			<job-pregress-card :jobInfo="item"></job-pregress-card>
		</view>
		
		
	</view>
</template>

<script>
	import jobPregressCard from '@/subpageA/components/jobProgressCard.vue'
	import uTabs from '@/subpageA/uview-ui/components/u-tabs/u-tabs.vue'
	
	export default {
		data() {
			return {
				itemList:[{
                    name: '全部',
					badge:{
						value:0
					}
                }, {
                    name: '已报名',
					badge:{
						value:0
					}
                }, {
                    name: '已录取',
					badge:{
						value:0
					}
                }, {
                    name: '已完成',
					badge:{
						value:0
					}
                }],
				preItemIndex:0,		//当前tab选择栏的选中索引
				
				
				
				presentList:[]	//当前展示的职位进展列表
			}
		},
		components:{
			jobPregressCard,
			uTabs
		},
		onLoad() {
			
			
			
			this.$store.dispatch('initDic').then(()=>{
				this.$http.request({
					url:'/user/enrolls',
					data:{
						startPage:0,
						type:0
					}
				}).then((result)=>{
					let res=result.data
					console.log('响应结果',res);
					if(res.code==200){
						this.presentList=res.data.enrollLists
						if (this.presentList) {
							this.itemList[0].badge.value=this.presentList.length	//这是uview-ui的tab组件的参数
						}
					}
					
				})
			})
			
			
		},
		//触底加载
		onReachBottom(){
			console.log('触底加载');
		},
		methods: {
			tabClick(e){
				//console.log(e);
				//职位进展状态：已取消-1，未录取-2，已评价-3，已结算-4，待录取-5，已录取-6
				// if(e.index===0){
				// 	this.presentList=this.jobPregressCardList;
				// }else if(e.index===1){
				// 	let tempList=[];
				// 	for(let v of this.jobPregressCardList){
				// 		if(v.status===5){
				// 			tempList.push(v);
				// 		}
				// 	}
				// 	this.presentList=tempList;
				// }else if(e.index===2){
				// 	let tempList=[];
				// 	for(let v of this.jobPregressCardList){
				// 		if(v.status===6){
				// 			tempList.push(v);
				// 		}
				// 	}
				// 	this.presentList=tempList;
				// }else{
				// 	let tempList=[];
				// 	for(let v of this.jobPregressCardList){
				// 		if(v.status!==5&&v.status!==6){
				// 			tempList.push(v);
				// 		}
				// 	}
				// 	this.presentList=tempList;
				// }
				
				if(e.index!==this.preItemIndex){
					this.$http.request({
						url:'/user/enrolls',
						data:{
							startPage:0,
							type:e.index-1,
						}
					}).then((result)=>{
						let res=result.data
						console.log('响应结果',res);
						this.presentList=res.data.enrollLists
						this.itemList[this.preItemIndex].badge.value=0;
						if (this.presentList) {
							this.itemList[e.index].badge.value=this.presentList.length;
						}
						this.preItemIndex=e.index;		//修改当前tab选中栏索引
					})
					
					
					
				}
				
			},
			
		}
	}
</script>

<style scoped lang="scss">
	.content{
		width: 100%;
		min-height: 100vh;
		background-color:  #F3F7F8;
		
		.topTab{
			background-color: #FFFFFF;
			display: flex;
		}
	}
</style>
